import service from './request'


export function Punchcard(data) {
    return service.post('/punchcard', data)
}
export function Punchcardyang(data) {
    return service.post('/punchcard?yangben=True', data)
}

export function getchuqindata(id, datetime, pagesize, pagenum) {
    return service.get('/punchcard?id=' + id + '&datetime=' + datetime + '&pagesize=' + pagesize + '&pagenum=' + pagenum)
}

export function getalljzgchuqin(data, pagesize, pagenum) {
    const { depart, level, zhiwei, teacher } = data
    const searchstudent = []
    searchstudent.push({ 'value': depart, 'value1': 'depart=' + depart + '&' })
    searchstudent.push({ 'value': level, 'value1': 'level=' + level + '&' })
    searchstudent.push({ 'value': zhiwei, 'value1': 'zhiwei=' + zhiwei + '&' })
    searchstudent.push({ 'value': teacher, 'value1': 'teacher=' + teacher + '&' })
    let src = ''
    searchstudent.forEach(item => {
        if (item.value || typeof(item.value) == 'number') {
            src += item.value1
        }
    })
    if (depart || level || zhiwei || teacher) {
        console.log('搜索', src)
        return service.get('/punchcard2?' + src + 'pagenum=' + pagenum + '&pagesize=' + pagesize)
    }
    return service.get('/punchcard2?pagesize=' + pagesize + '&pagenum=' + pagenum)
}

//不打卡  （修改数据）
export function editbudaka(id, date, start, end) {
    return service.put(`/editbudaka?id=${id}&date=${date}&start=${start}&end=${end}`)
}